<template>
  <el-dialog
    custom-class="sc-dialog sc-dialog-mini"
    :visible.sync="open"
    :close-on-click-modal="false"
    :append-to-body="true"
    @click.native.stop
  >
    <div class="dialog-container">
      <LoginPlugin @loginSuccess="handleLoginSuccess"></LoginPlugin>
    </div>
  </el-dialog>
</template>

<script>
import { mapState } from "vuex";

import { labelTypePrivate, labelTypeTeam } from "@/constant";
import "splitpanes/dist/splitpanes.css";
//组件
import LoginPlugin from "./LoginPlugin.vue";

const DIALOG_KEY = "LoginPluginDlg";

export default {
  name: DIALOG_KEY,
  components: { LoginPlugin },
  data() {
    return {
      isOperated: false,
      selectedFolderTeam: null,
      activeTreeTab: labelTypeTeam,
      labelTypeTeam,
      labelTypePrivate
    };
  },
  computed: {
    ...mapState("orange", {
      dialogInfo: state => state.dialog[DIALOG_KEY]
    }),
    open: {
      get() {
        return !!this.$isOpen(DIALOG_KEY);
      },
      set(newValue) {
        if (newValue) {
          throw new Error("打开弹窗请直接使用 this.$openDialog");
        } else {
          this.$EventBus.$emit("close" + DIALOG_KEY, false);
          this.$closeDialog(DIALOG_KEY);
        }
      }
    },
    resFormData() {
      return this.formData;
    }
  },
  methods: {
    async handleLoginSuccess() {
      this.open = false;
    },
    /** 锁定异步事件，防止重复触发 */
    async lockAction(func) {
      this.isOperated = true;
      try {
        await func();
      } finally {
        this.isOperated = false;
      }
    }
  },
  created() {},
  destroyed() {}
};
</script>

<style lang="scss" scoped>
.dialog-container {
}
</style>
